﻿/**
 * SLURM FRAMEWORK
 * VERSION: Beta 1.0
 * DATE: 2012-06-13
 * AUTHOR: Ezequiel Soler
 * GNU Lesser GPL
 **/
package com.slurm
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import com.greensock.*;
	import com.greensock.easing.*;

	public class ButtonZone extends MovieClip
	{
		public var id:Number;
		public var idScreen:Number;
		public function ButtonZone()
		{
			if (stage)
			{
				init();
			}
			else
			{
				addEventListener(Event.ADDED_TO_STAGE, init);
			}
		}

		private function init(e:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			this.addEventListener(Event.ENTER_FRAME,checkZone);
			this.buttonMode = true;
			
		}
		
		private function checkZone(e:Event){
			try{
			if(enabled){
			if((stage.mouseX > this.x && stage.mouseX < (this.x+this.width)) && (stage.mouseY > this.y && stage.mouseY < (this.y+this.height))){
				this.gotoAndStop('over');
			}else{
				this.gotoAndStop('out');
			}
			}
			}catch(error:Error){
				this.removeEventListener(Event.ENTER_FRAME, checkZone);
			}
		}

		private function over(e:MouseEvent)
		{
			this.gotoAndStop('over');
		}

		private function out(e:MouseEvent)
		{
			this.gotoAndStop('out');
		}

		public function desactive()
		{
			this.buttonMode = false;
		}

		public function active()
		{
			this.buttonMode = true;
		}

		public function disabled()
		{
			enabled = false;
			TweenMax.to(this, 1, {colorMatrixFilter:{saturation:0}});
			this.buttonMode = false;
		}
		
		public function setProperties(paramsProp:XML){
			
		}

	}

}